package com.ruoyi.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.TbCompanyMerchantChatRecord;
import com.ruoyi.system.service.ITbCompanyMerchantChatRecordService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 公司-商家：客服聊天记录Controller
 * 
 * @author hkj
 * @date 2024-09-09
 */
@RestController
@RequestMapping("/companyMerchantChatRecord")
public class TbCompanyMerchantChatRecordController extends BaseController
{
    @Autowired
    private ITbCompanyMerchantChatRecordService tbCompanyMerchantChatRecordService;

    /**
     * 查询公司-商家：客服聊天记录列表
     */
//    @RequiresPermissions("system:companyMerchantChatRecord:list")
    @GetMapping("/list")
    public TableDataInfo list(TbCompanyMerchantChatRecord tbCompanyMerchantChatRecord)
    {
        startPage();
        List<TbCompanyMerchantChatRecord> list = tbCompanyMerchantChatRecordService.selectTbCompanyMerchantChatRecordList(tbCompanyMerchantChatRecord);
        return getDataTable(list);
    }

    /**
     * 导出公司-商家：客服聊天记录列表
     */
    @RequiresPermissions("system:companyMerchantChatRecord:export")
    @Log(title = "公司-商家：客服聊天记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbCompanyMerchantChatRecord tbCompanyMerchantChatRecord)
    {
        List<TbCompanyMerchantChatRecord> list = tbCompanyMerchantChatRecordService.selectTbCompanyMerchantChatRecordList(tbCompanyMerchantChatRecord);
        ExcelUtil<TbCompanyMerchantChatRecord> util = new ExcelUtil<TbCompanyMerchantChatRecord>(TbCompanyMerchantChatRecord.class);
        util.exportExcel(response, list, "公司-商家：客服聊天记录数据");
    }

    /**
     * 获取公司-商家：客服聊天记录详细信息
     */
    @RequiresPermissions("system:companyMerchantChatRecord:query")
    @GetMapping(value = "/{recordId}")
    public AjaxResult getInfo(@PathVariable("recordId") Long recordId)
    {
        return success(tbCompanyMerchantChatRecordService.selectTbCompanyMerchantChatRecordByRecordId(recordId));
    }

    /**
     * 新增公司-商家：客服聊天记录
     */
    @RequiresPermissions("system:companyMerchantChatRecord:add")
    @Log(title = "公司-商家：客服聊天记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbCompanyMerchantChatRecord tbCompanyMerchantChatRecord)
    {
        return toAjax(tbCompanyMerchantChatRecordService.insertTbCompanyMerchantChatRecord(tbCompanyMerchantChatRecord));
    }

    /**
     * 修改公司-商家：客服聊天记录
     */
    @RequiresPermissions("system:companyMerchantChatRecord:edit")
    @Log(title = "公司-商家：客服聊天记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbCompanyMerchantChatRecord tbCompanyMerchantChatRecord)
    {
        return toAjax(tbCompanyMerchantChatRecordService.updateTbCompanyMerchantChatRecord(tbCompanyMerchantChatRecord));
    }

    /**
     * 删除公司-商家：客服聊天记录
     */
    @RequiresPermissions("system:companyMerchantChatRecord:remove")
    @Log(title = "公司-商家：客服聊天记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordIds}")
    public AjaxResult remove(@PathVariable Long[] recordIds)
    {
        return toAjax(tbCompanyMerchantChatRecordService.deleteTbCompanyMerchantChatRecordByRecordIds(recordIds));
    }
}
